<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /fasttmp/mkdist-qt-4.3.5-1211793125/qtopia-core-opensource-src-4.3.5/doc/src/q3ptrdict.qdoc -->
<head>
  <title>Qt 4.3: Q3PtrDictIterator Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">Q3PtrDictIterator Class Reference<br /><sup><sup>[<a href="qt3support.html">Qt3Support</a> module]</sup></sup></h1>
<p>The Q3PtrDictIterator class provides an iterator for <a href="q3ptrdict.html">Q3PtrDict</a> collections. <a href="#details">More...</a></p>
<pre> #include &lt;Q3PtrDictIterator&gt;</pre><p><b>This class is part of the Qt 3 support library.</b> It is provided to keep old source code working. We strongly advise against using it in new code. See <a href="porting4.html">Porting to Qt 4</a> for more information.</p>
<ul>
<li><a href="q3ptrdictiterator-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="q3ptrdictiterator.html#Q3PtrDictIterator">Q3PtrDictIterator</a></b> ( const Q3PtrDict&lt;type&gt; &amp; <i>dict</i> )</li>
<li><div class="fn"/><b><a href="q3ptrdictiterator.html#dtor.Q3PtrDictIterator">~Q3PtrDictIterator</a></b> ()</li>
<li><div class="fn"/>uint <b><a href="q3ptrdictiterator.html#count">count</a></b> () const</li>
<li><div class="fn"/>type * <b><a href="q3ptrdictiterator.html#current">current</a></b> () const</li>
<li><div class="fn"/>void * <b><a href="q3ptrdictiterator.html#currentKey">currentKey</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="q3ptrdictiterator.html#isEmpty">isEmpty</a></b> () const</li>
<li><div class="fn"/>type * <b><a href="q3ptrdictiterator.html#toFirst">toFirst</a></b> ()</li>
<li><div class="fn"/><b><a href="q3ptrdictiterator.html#operator-type--2a">operator type *</a></b> () const</li>
<li><div class="fn"/>type * <b><a href="q3ptrdictiterator.html#operator-28-29">operator()</a></b> ()</li>
<li><div class="fn"/>type * <b><a href="q3ptrdictiterator.html#operator-2b-2b">operator++</a></b> ()</li>
<li><div class="fn"/>type * <b><a href="q3ptrdictiterator.html#operator-2b-eq">operator+=</a></b> ( uint <i>jump</i> )</li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The Q3PtrDictIterator class provides an iterator for <a href="q3ptrdict.html">Q3PtrDict</a> collections.</p>
<p>Q3PtrDictIterator is implemented as a template class. Define a template instance Q3PtrDictIterator&lt;X&gt; to create a dictionary iterator that operates on <a href="q3ptrdict.html">Q3PtrDict</a>&lt;X&gt; (dictionary of X*).</p>
<p>Example:</p>
<pre> Q3PtrDict&lt;char&gt; fields;

 QLineEdit *le1 = new QLineEdit( this );
 le1-&gt;setText( &quot;Simpson&quot; );
 QLineEdit *le2 = new QLineEdit( this );
 le2-&gt;setText( &quot;Homer&quot; );
 QLineEdit *le3 = new QLineEdit( this );
 le3-&gt;setText( &quot;45&quot; );

 fields.insert( le1, &quot;Surname&quot; );
 fields.insert( le2, &quot;Forename&quot; );
 fields.insert( le3, &quot;Age&quot; );

 Q3PtrDictIterator&lt;char&gt; it( fields );
 for( ; it.current(); ++it ) {
     QLineEdit *le = (QLineEdit)it.currentKey();
     cout &lt;&lt; it.current() &lt;&lt; &quot;: &quot; &lt;&lt; le-&gt;text() &lt;&lt; endl;
 }
 cout &lt;&lt; endl;

<span class="comment"> //</span> Output (random order):
<span class="comment"> //</span>  Forename: Homer
<span class="comment"> //</span>  Age: 45
<span class="comment"> //</span>  Surname: Simpson</pre>
<p>In the example we insert some line edits into a dictionary, associating a string with each. We then iterate over the dictionary printing the associated strings.</p>
<p>Multiple iterators may independently traverse the same dictionary. A <a href="q3ptrdict.html">Q3PtrDict</a> knows about all the iterators that are operating on the dictionary. When an item is removed from the dictionary, <a href="q3ptrdict.html">Q3PtrDict</a> updates all iterators that refer the removed item to point to the next item in the traversing order.</p>
<p>See also <a href="q3ptrdict.html">Q3PtrDict</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="Q3PtrDictIterator"></a>Q3PtrDictIterator::Q3PtrDictIterator ( const <a href="q3ptrdict.html">Q3PtrDict</a>&lt;type&gt; &amp; <i>dict</i> )</h3>
<p>Constructs an iterator for <i>dict</i>. The current iterator item is set to point on the first item in the <i>dict</i>.</p>
<h3 class="fn"><a name="dtor.Q3PtrDictIterator"></a>Q3PtrDictIterator::~Q3PtrDictIterator ()</h3>
<p>Destroys the iterator.</p>
<h3 class="fn"><a name="count"></a><a href="qtglobal.html#uint-typedef">uint</a> Q3PtrDictIterator::count () const</h3>
<p>Returns the number of items in the dictionary this iterator operates on.</p>
<p>See also <a href="q3ptrdictiterator.html#isEmpty">isEmpty</a>().</p>
<h3 class="fn"><a name="current"></a>type * Q3PtrDictIterator::current () const</h3>
<p>Returns a pointer to the current iterator item's value.</p>
<h3 class="fn"><a name="currentKey"></a>void * Q3PtrDictIterator::currentKey () const</h3>
<p>Returns the current iterator item's key.</p>
<h3 class="fn"><a name="isEmpty"></a>bool Q3PtrDictIterator::isEmpty () const</h3>
<p>Returns TRUE if the dictionary is empty; otherwise returns FALSE.</p>
<p>See also <a href="q3ptrdictiterator.html#count">count</a>().</p>
<h3 class="fn"><a name="toFirst"></a>type * Q3PtrDictIterator::toFirst ()</h3>
<p>Sets the current iterator item to point to the first item in the dictionary and returns a pointer to the item. If the dictionary is empty, it sets the current item to 0 and returns 0.</p>
<h3 class="fn"><a name="operator-type--2a"></a>Q3PtrDictIterator::operator type * () const</h3>
<p>Cast operator. Returns a pointer to the current iterator item. Same as <a href="q3ptrdictiterator.html#current">current</a>().</p>
<h3 class="fn"><a name="operator-28-29"></a>type * Q3PtrDictIterator::operator() ()</h3>
<p>Makes the succeeding item current and returns the original current item.</p>
<p>If the current iterator item was the last item in the dictionary or if it was 0, 0 is returned.</p>
<h3 class="fn"><a name="operator-2b-2b"></a>type * Q3PtrDictIterator::operator++ ()</h3>
<p>Prefix ++ makes the succeeding item current and returns the new current item.</p>
<p>If the current iterator item was the last item in the dictionary or if it was 0, 0 is returned.</p>
<h3 class="fn"><a name="operator-2b-eq"></a>type * Q3PtrDictIterator::operator+= ( <a href="qtglobal.html#uint-typedef">uint</a> <i>jump</i> )</h3>
<p>Sets the current item to the item <i>jump</i> positions after the current item and returns a pointer to that item.</p>
<p>If that item is beyond the last item or if the dictionary is empty, it sets the current item to 0 and returns 0.</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2008 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.3.5</div></td>
</tr></table></div></address></body>
</html>
